home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / .bin / httpd / Solaris_1 / jpgtmp.pl < prev    next >
Perl Script  |  1996-02-29  |  13KB  |  386 lines

  1. #!/usr/lab/bin/perl
  2.  
  3. # ------------------------------------------------------------
  4.  
  5. # edit_info.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  6. # This allows the user to edit or create the _info file
  7. # necessary for the CDware.
  8.  
  9. # ------------------------------------------------------------
  10.  
  11. # Bugs and other fixes
  12.  
  13. # ------------------------------------------------------------
  14. %Categories = (
  15. "archive", "Archiving, Storage Management & Backup Solutions"
  16. ,"business", "Business Solutions"
  17. , "cad_cae", "CAD/CAE"
  18. , "catalogs", "Catalogs"
  19. , "client_server", "Client/Server Solutions"
  20. , "desktop_apps", "Desktop Applications"
  21. , "doc_mgt", "Document Management"
  22. , "epubs", "Electronic Publishing"
  23. , "graphics_imaging", "Graphics and Imaging"
  24. , "info_mgt", "Information Management"
  25. , "multimedia", "Multimedia"
  26. , "networking", "Networking"
  27. , "security", "Security"
  28. , "sw_eng", "Software Engineering"
  29. ,"sys_admin", "System Administration"
  30. , "telco", "Telecommunications"
  31. , "training", "Training"
  32. , "Hardware", "Hardware"
  33. , "Services", "Services"
  34. , "Sun", "Sun"
  35. , "Info", "Info"
  36. );
  37.  
  38. @PlatOrder = ("S2", "S1", "S2x86", "S2PPC");
  39.  
  40. %Platforms = (
  41. "S1", "Solaris 1 (SunOS 4)"
  42. , "S2", "Solaris 2 SPARC"
  43. , "S2x86", "Solaris 2 Intel"
  44. , "S2PPC", "Solaris 2 PowerPC"
  45. );
  46.  
  47. sub IsSelected
  48. {
  49.     local($KeyCat) = @_;
  50.     @fields = split(/\s+/, $ChosenCat);
  51.     foreach $idem (@fields) {
  52.         if ($idem eq $KeyCat) {
  53.             "SELECTED";
  54.             last;
  55.         }
  56.     }
  57. }
  58.  
  59. sub UnCapitalizedSort
  60. {
  61.     ($al = $a) =~ tr/A-Z/a-z/;
  62.     ($bl = $b) =~ tr/A-Z/a-z/;
  63.     $al cmp $bl;
  64. }
  65.  
  66. ##############################################################################
  67. # WriteForm: Write the form to be filled by the user
  68. ##############################################################################
  69. sub WriteForm
  70. {
  71.     $~ = "MAININFO";
  72.     write STDOUT;
  73.  
  74.     $~ = "PLATINFO";
  75.     #foreach $NickPlat (sort UnCapitalizedSort keys(%Platforms)) {
  76.     foreach $NickPlat (@PlatOrder) {
  77.         write STDOUT;
  78.     }
  79.  
  80.     $~ = "MIDINFO";
  81.     write STDOUT;
  82.  
  83.     $~ = "CATINFO";
  84.     foreach $NickCat (sort UnCapitalizedSort keys(%Categories)) {
  85.         $CatName = $Categories{$NickCat};
  86.         unless ($CatName =~ /^!.*/) {
  87.             write STDOUT;
  88.         }
  89.     }
  90.  
  91.     $~ = "ENDINFO";
  92.     write STDOUT;
  93. }
  94. ##############################################################################
  95. # CreateHTML: Create an HTML page initialized with the _info file content
  96. ##############################################################################
  97. sub CreateHTML
  98. {
  99.     if (-s $INFOFILENAME && open (INFOFILE, $INFOFILENAME)) {
  100.         $LINE=<INFOFILE>;
  101.         ($Company, $Description, $Platform, $ChosenCat, $WebSite, $Email, $HomePageName) = split(/\^/, $LINE);
  102.         #$Company="value=\"" . $Company . "\"";
  103.         #$Description="value=\"" . $Description . "\"";
  104.         #$WebSite="value=\"" . $WebSite . "\"";
  105.         #$Email="value=\"" . $Email . "\"";
  106.     
  107.         @fields = split(/\s+/, $Platform . " " . $ChosenCat);
  108.         foreach $idem (@fields) {
  109.             $Checked{$idem} = "CHECKED"
  110.         }
  111.         while (<INFOFILE>) {
  112.             $Product=$_;
  113.             chop($Product);
  114.             chop($Product);
  115.             push(@Products, $Product );
  116.         }
  117.     } else {
  118.         print STDOUT "Can't open $INFOFILENAME";
  119.     }
  120.  
  121.     $HomePageName= ($HomePageName =~ /^ *$/?"index.html":$HomePageName) ;
  122.  
  123.     #$~ = "HTMLHEADER";
  124.     #write STDOUT;
  125.  
  126.     #&WriteForm();
  127. }
  128.  
  129. sub url_decode
  130. {
  131.  
  132. #       Decode a URL encoded string or array of strings
  133. #               + -> space
  134. #               %xx -> character xx
  135.  
  136.  
  137.     foreach (@_) {
  138.         tr/+/ /;
  139.         s/%0a //g;
  140.         s/\^//g;
  141.         s/%(..)/pack("c",hex($1))/ge;
  142.     }
  143.     @_;
  144. }
  145.  
  146. sub Init
  147. {
  148.     local($comp, $errMes) = @_;
  149.     $comp=$rqpairs{$comp};
  150.     #if ($comp eq "") {
  151.         #$Status = &PrintErr($errMes);
  152.     #}
  153.     $comp;
  154. }
  155.  
  156. sub WriteInfo
  157. {
  158.     local($old);
  159.     #$~ = "HTMLHEADER";
  160.     #write STDOUT;
  161.  
  162.     #@names = &url_decode(split(/[&=]/, $request));
  163.     #%rqpairs = @names;
  164.     open (INFOFILE, "> $INFOFILENAME") || print STDOUT "Can't write $INFOFILENAME";
  165.     $old = select(INFOFILE);
  166.  
  167.     #$Company = &Init("CompanyName", "MisCompany");
  168.     #$Description = &Init("Description", "MisDescription");
  169.     #$Description =~ s/^[-     ]*/- /;
  170.     #$WebSite = $rqpairs{"WebSite"};
  171.     $WebSite =~ s/\n//;
  172.     $Email =~ s/\n//;
  173.     #$WebSite =~ s/^http:\/\///;
  174.     ##$WebSite =~ s/\/$//;
  175.     #$Email = $rqpairs{"Email"};
  176.     #$HomePageName = &Init("Home", "MisHome");;
  177.     #$Products[0] = &Init("Product1", "MisProduct1");
  178.     #$Products[1] = $rqpairs{"Product2"};
  179.     #$Products[2] = $rqpairs{"Product3"};
  180.  
  181.     #substr($Company, 0, 1) =~ tr/a-z/A-Z/;
  182.     print $Company . "^" . $Description . "^$Platform";
  183.     #print ($Checked{"hasSlide"} eq "CHECKED" ? "demo ":"");
  184.     #print ($Checked{"hasTryIt"} eq "CHECKED" ? "testdrive ":"");
  185.     #print ($Checked{"hasInstall"} eq "CHECKED" ? "install":"");
  186.     print ($ChosenCat =~ /S2/ ? "^$ChosenCat^":"^S2 $ChosenCat^");
  187.     #%RevCat = reverse %Categories;
  188.     #%RevPlat = reverse %Platforms;
  189.     #$foundCat = $foundPlat = 0;
  190.         #($Company, $Description, $Platform, $ChosenCat, $WebSite, $Email, $HomePageName) = split(/\^/, $LINE);
  191.     #$ChosenCat = "";
  192.     #$Checked{$idem} = "CHECKED"
  193.     #for ($iname = 0; $iname < @names; $iname+=2) {
  194.         #if ($names[$iname] eq "Menu_Cat") {
  195.             #$ChosenCat = $ChosenCat . $RevCat{$names[$iname + 1]} . " ";
  196.             #print $RevCat{$names[$iname + 1]} . " ";
  197.     #print ($Checked{"hasInstall"} eq "CHECKED" ? "install":"");
  198.             #$foundCat++;
  199.         #} elsif ($names[$iname] eq "Menu_Plat") {
  200.             #$buf = $names[$iname + 1];
  201.             #$buf =~ s/ *$//;
  202.             #$Checked{$RevPlat{$buf}} = "CHECKED";
  203.             #print $RevPlat{$buf} . " ";
  204.             #$foundPlat++;
  205.         #}
  206.     #}
  207.     #if ($foundPlat == 0) {
  208.         #$Status = &PrintErr("MisPlat");
  209.     #}
  210.     if ($foundCat == 0) {
  211.         #$Status = &PrintErr("MisCat");
  212.     } elsif ($foundCat > 3) {
  213.         #$Status = &PrintErr("TooManyCat");
  214.     }
  215.     #$WebSite =~ s/[     ]//g;
  216.     #$Email =~ s/[     ]//g;
  217.     #$HomePageName =~ s/[     ]//g;
  218.     print "$WebSite^$Email^$HomePageName^\n";
  219.     print "$Products[0]^\n";
  220.     if ($Products[1] ne "") {
  221.         print "$Products[1]^\n";
  222.     }
  223.     if ($Products[2] ne "") {
  224.         print "$Products[2]^\n";
  225.     }
  226.     @Products=();
  227.     close(INFOFILE);
  228.     select($old);
  229.     if ($Status == 1) {
  230.         #$Company="value=\"" . $Company . "\"";
  231.         #$Description="value=\"" . $Description . "\"";
  232.         #$WebSite="value=\"" . $WebSite . "\"";
  233.         #$Email="value=\"" . $Email . "\"";
  234.         #$HomePageName="value=\"" . $HomePageName . "\"";
  235.         #($rqpairs{"hasSlide"} eq "yes" ? $Checked{"demo"} = "CHECKED":null);
  236.         #($rqpairs{"hasTryIt"} eq "yes" ? $Checked{"testdrive"} = "CHECKED":null);
  237.         #($rqpairs{"hasInstall"} eq "yes" ? $Checked{"install"} = "CHECKED":null);
  238.         #for ($iprod = 0; $iprod < 3; $iprod++) {
  239.             #$Products[$iprod]= "value=\"" . $Products[$iprod] . "\"";
  240.         #}
  241.         #&WriteForm();
  242.     } else {
  243.         #$~ = "GOODRESULT";
  244.         #write STDOUT;
  245.         #print STDOUT "Weird for $INFOFILENAME\n";
  246.     }
  247. }
  248.  
  249. ##############################################################################
  250. # Main block
  251. ##############################################################################
  252. #require 'devinfo.pl';
  253. #require 'tools.pl';
  254. #$HomeDir = &GetDevinfo("dir");
  255.  
  256. $Checked{"S2"} = "CHECKED";
  257. $ListDir = `ls */_info`;
  258. #$ListDir =~ s/hotjava\n|CDware\n|tmp\n|DEV\n|([^     \n]*\.Z)//g;
  259. #$ListDir =~ s/(.*)\n+/<OPTION>\1\n/g;
  260.  
  261. @filefields = split(/\s+/, $ListDir);
  262. print $filefields;
  263. foreach $INFOFILENAME (@filefields) {
  264.     #$HomeDir = ".";
  265.     #$INFOFILENAME = "$HomeDir/_info";
  266.     if ( -s $INFOFILENAME) {
  267.         print "Working with $INFOFILENAME\n";
  268.         #system("cp $INFOFILENAME.jpg.bck $INFOFILENAME");
  269.         system("cp $INFOFILENAME $INFOFILENAME.jpg.bck");
  270.     
  271.         &CreateHTML;
  272.         &WriteInfo;
  273.     }
  274. }
  275.  
  276. ################################################################################
  277. # Define FORMATS (no more code)
  278. ################################################################################
  279. format HTMLHEADER =
  280. Content-type: text/html
  281.  
  282.  
  283. <html>
  284. <title>Developer's Kit: edit information</title>
  285. <body>
  286. .
  287.  
  288. format MAININFO =
  289. <h1>Please enter this information and click on "Ok":</h1>
  290. <h4>Currently working with <b>"@*
  291. $HomeDir
  292. " directory</h4>
  293. #<p>You 're currently editing <b>@* 
  294. #$INFOFILENAME
  295. </b><form method="post"  ACTION="http://localhost:7999/cgi-bin/edit_info.pl">
  296. #<h4>CDware _info file: </h4>
  297. <ul><IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">: necessary
  298. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif">: Optional.</ul>
  299. <pre><IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Company name:       <input type="text" 
  300. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  301. $Company
  302.  name="CompanyName" size="25" maxlength=50>
  303. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Brief description:  <input type="text"
  304. ~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  305. $Description
  306.  name="Description" size=40 MAXLENGTH=160>
  307. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">First Product Name: <input type="text"
  308. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  309. $Products[0]
  310.  name="Product1" size="35" maxlength=50>
  311. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif">Second Product Name:<input type="text"
  312. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  313. $Products[1]
  314.  name="Product2" size="35" maxlength=50>
  315. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif">Third Product Name: <input type="text"
  316. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  317. $Products[2]
  318.  name="Product3" size="35" maxlength=50><br>
  319. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif">Address of your web site: http://<input type="text"
  320. ~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  321. $WebSite
  322.  name="WebSite" size=28 MAXLENGTH=160>/
  323. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif">Email for information request:   <input type="text"
  324. ~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  325. $Email
  326.  name="Email" size=28 MAXLENGTH=160>
  327. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Filename of your home page:      <input type="text"
  328. ~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  329. $HomePageName
  330.  name="Home" size=28 MAXLENGTH=160>
  331. </pre>
  332. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Specify if there will be a Slide-show or a version of your product available for evaluation in your submission:
  333. <ul><ul>
  334. <input type="checkbox" NAME="hasSlide" VALUE="yes" @<<<<<<<<< size="8" >Slide-show available<br>
  335. $Checked{"demo"}
  336. <input type="checkbox" NAME="hasTryIt" VALUE="yes" @<<<<<<<<< size="8" >Trial software available<br>
  337. $Checked{"testdrive"}
  338. <input type="checkbox" NAME="hasInstall" VALUE="yes" @<<<<<<<<<< size="8" >Unlockable available<br>
  339. $Checked{"install"}
  340. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif"><b>Note:</b> If you do NOT have any of the above, please continue.<br>
  341. </ul></ul>
  342. <p><IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Specify which platforms you're supporting (at least one):
  343. <ul><ul>
  344. .
  345.  
  346. format PLATINFO =
  347. <input type="checkbox" NAME="Menu_Plat" VALUE="@<<<<<<<<<<<<<<<<<<" @<<<<<<<<<< size="8" >@<<<<<<<<<<<<<<<<<<< <br>
  348. $Platforms{$NickPlat}, $Checked{$NickPlat}, $Platforms{$NickPlat}
  349. .
  350.  
  351. format MIDINFO =
  352. </ul></ul>
  353. <IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif">Choose one to three categories:<br><center><SELECT NAME="Menu_Cat" size="10" MULTIPLE>
  354. .
  355.  
  356. format CATINFO =
  357. <OPTION @<<<<<<<<> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <br>
  358. &IsSelected($NickCat), $CatName
  359. .
  360.  
  361. format ENDINFO =
  362. </SELECT></center><br>
  363. <P><center>
  364. <input type="submit" VALUE="Ok" >
  365. <input type="Reset" VALUE="Cancel" >
  366. </center>
  367. </FORM>
  368. <hr><h5><p><A HREF=file:///tmp/httpd/.products/CDware/Help/SMICopyright.html>Copyright</A> 1995 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043 USA.  All rights reserved.</h5><br></pre>
  369. <a href=file:///tmp/httpd/.products/DEV/credits.html>Credits</a>
  370. </b>
  371. </body>
  372. </html>
  373. .
  374.  
  375.  
  376. format GOODRESULT =
  377. <h1><app class="ImageLoopItem" img="file:///tmp/httpd/.products/DEV/images/duke" width=55 height=68>Congratulations! </h1>
  378. <p>You completed the first step of the creation of your submssion to the CDware.
  379. <p>You can edit this information again at any time from the main menu !
  380. <h4><p><A HREF="http://localhost:7999/cgi-bin/mainmenu.pl? ">Go to main menu</A> </h4><br>
  381. #<hr><h5><p><A HREF=file:///tmp/httpd/.products/CDware/Help/SMICopyright.html>Copyright</A> 1995 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043 USA.  All rights reserved.</h5><br></pre>
  382. #<a href=file:///tmp/httpd/.products/DEV/credits.html>Credits</a>
  383. </body>
  384. </html>
  385. .
  386.